<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    // es10
    // flat将多维数组转化成低位数组(降维)
    let arr = [1, 2, 3, [4, 5, 6, [7, 8, 9]]];
    // flat参数是扁平化深度，默认是1
    console.log(arr.flat());
    console.log(arr.flat(2));

    // flatMap 方法首先使用映射函数映射每个元素，然后使用 flat 方法将嵌套数组“拉平”。
    let arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9];
    console.log(arr1.flatMap(item => [item * 10]));
</script>

</html>